from orders.models import OrderInfo,OrderGoods
from goods.models import SKU
from rest_framework import serializers


class SKUSerializer(serializers.ModelSerializer):

    class Meta:
        model = SKU
        fields = ('name','default_image')


class OrderDetialSerializer(serializers.ModelSerializer):
    sku = SKUSerializer(read_only=True)

    class Meta:
        model = OrderGoods
        fields = ('count','price','sku')


class OrderSerializer(serializers.ModelSerializer):
    user = serializers.StringRelatedField()
    skus = OrderDetialSerializer(many=True)
    class Meta:
        model = OrderInfo
        fields = '__all__'







